package com.tencent.compose.sample.kotlinx

import io.ktor.client.HttpClient
import io.ktor.client.HttpClientConfig
import io.ktor.client.engine.ProxyBuilder
import io.ktor.client.engine.curl.Curl
import io.ktor.client.engine.engines
import io.ktor.client.engine.http
import io.ktor.client.plugins.defaultRequest
import io.ktor.client.request.header

actual fun httpClientPlatform(block: HttpClientConfig<*>.() -> Unit): HttpClient = HttpClient(Curl) {
    engine {
        // 指定 Charles 代理地址（替换成你本机局域网 IP 和端口）
        proxy = ProxyBuilder.http("http://172.16.155.178:8888/")

        // Charles 默认用自签证书，这里关闭 SSL 校验
        sslVerify = false
    }

    defaultRequest {
        // 可选：增加调试 header，方便在 Charles 里识别
        header("X-Debug-From", "HarmonyOS")
    }

    // 保留调用方传入的配置
    block()
}